{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=1596
  Verdict: Accepted
}
uses
	SysUtils, Math;
 
var 
	i,j,n,m,cur:longint;
	a:array[0..110,0..110] of longint;
	f:boolean;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(n,m);
for i:=1 to n do
	for j:=1 to m do
		read(a[i][j]);
for i:=1 to n do begin
	cur:=1;
	for j:=2 to m do
		if a[i][j]<a[i][cur] then cur:=j;
	a[i][0]:=cur;
end;
for j:=1 to m do begin
	cur:=1;
	for i:=2 to n do
		if a[i][j]>a[cur][j] then cur:=i;
	a[0][j]:=cur;
end;
f:=false;
for i:=1 to n do
	for j:=1 to m do
		if (a[i][0]=j) and (a[0][j]=i) then begin
			f:=true;
			writeln(i,' ',j);
		end;
if not f then write(0);
end.